//定义关于counter的store
import { defineStore } from 'pinia'
//defineStore 是返回一个函数 函数命名最好有use前缀，根据函数来进行下一步操作
const useHandleNumber = defineStore('useHandleNumber', ()=>{
    let num = ref(99)
    let dbNum = computed(()=>num.value*2)
    const addNumber = () => {
        num.value++
    }
    const reduceNumber = () => {
        setTimeout(()=>{
            num.value--
        },1000)
    }
    return {
        num,
        dbNum,
        addNumber,
        reduceNumber
    }
})
export default useHandleNumber